<template>
<div>
  <el-dialog
    :title="title"
    size="small"
    :close-on-click-modal="false"
     v-dialogDrag
    :visible.sync="visible">
    <el-form size="small" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method==='view'"
             label-width="120px">
      <el-row  :gutter="15">
        <el-col :span="24">
            <el-form-item label="照片" prop="photo"
                :rules="[
                 ]">
              <el-upload ref="photo"
              v-if="visible"
              list-type="picture-card"
                    :action="`${this.$http.BASE_URL}/sys/file/webupload/upload?uploadPath=/basicdata/basicpeople/basicPeople`"
                    :headers="{token: $cookie.get('token')}"
                    :on-preview="(file, fileList) => {
                        $alert(`<img style='width:100%' src=' ${(file.response && file.response.url) || file.url}'/>`,  {
                          dangerouslyUseHTMLString: true,
                          showConfirmButton: false,
                          closeOnClickModal: true,
                          customClass: 'showPic'
                        });
                    }"
                    :on-success="(response, file, fileList) => {
                       inputForm.photo = fileList.map(item => (item.response && item.response.url) || item.url).join('|')
                    }"
                    :on-remove="(file, fileList) => {
                      $http.post(`/sys/file/webupload/deleteByUrl?url=${(file.response && file.response.url) || file.url}`).then(({data}) => {
                        $message.success(data.msg)
                      })
                      inputForm.photo = fileList.map(item => item.url).join('|')
                    }"
                    :before-remove="(file, fileList) => {
                      return $confirm(`确定移除 ${file.name}？`)
                    }"
                    multiple
                    :limit="1"
                    :on-exceed="(files, fileList) =>{
                      $message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`)
                    }"
                    :file-list="photoArra">
                    <i class="el-icon-plus"></i>
                  </el-upload>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="员工编号" prop="employeesCode"
                :rules="[
                 ]">
              <el-input v-model="inputForm.employeesCode" placeholder="请填写员工编号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="姓名" prop="peopleName"
                :rules="[
                 ]">
              <el-input v-model="inputForm.peopleName" placeholder="请填写姓名"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="性别" prop="gender"
                :rules="[
                 ]">
              <!-- <el-input v-model="inputForm.gender" placeholder="请填写性别"     ></el-input> -->
              <el-select v-model="inputForm.gender" placeholder="请填写性别" style="width:100%;" >
                <el-option v-for="item in $dictUtils.getDictList('gender')" :label="item.label" :value="item.value" :key="item.value"></el-option>
              </el-select>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="民族" prop="nation"
                :rules="[
                 ]">
              <el-input v-model="inputForm.nation" placeholder="请填写民族"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="出生年月" prop="birth"
                :rules="[
                 ]">
              <!-- <el-input v-model="inputForm.birth" placeholder="请填写出生年月"     ></el-input> -->
              <el-date-picker
                    value-format="yyyy.MM"
                    v-model="inputForm.birth"
                    type="month"
                    placeholder="选择日期">
                  </el-date-picker>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="身份证号" prop="idNumber"
                :rules="[
                 ]">
              <el-input v-model="inputForm.idNumber" placeholder="请填写身份证号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="电话号" prop="phoneNumber"
                :rules="[
                 ]">
              <el-input v-model="inputForm.phoneNumber" placeholder="请填写电话号"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="参工时间" prop="workTime"
                :rules="[
                 ]">
              <!-- <el-input v-model="inputForm.workTime" placeholder="请填写参工时间"     ></el-input> -->
              <el-date-picker
                    value-format="yyyy.MM"
                    v-model="inputForm.workTime"
                    type="month"
                    placeholder="选择参工日期">
                  </el-date-picker>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="入党时间" prop="partyTime"
                :rules="[
                 ]">
              <!-- <el-input v-model="inputForm.partyTime" placeholder="请填写入党时间"     ></el-input> -->
              <el-date-picker
                    value-format="yyyy.MM"
                    v-model="inputForm.partyTime"
                    type="month"
                    placeholder="选择入党日期">
                  </el-date-picker>
           </el-form-item>
        </el-col>
        <!-- <el-col :span="12">
            <el-form-item label="排序" prop="sort"
                :rules="[
                 ]">
              <el-input v-model="inputForm.sort" placeholder="请填写排序"     ></el-input>
           </el-form-item>
        </el-col> -->
        <el-col :span="12">
            <el-form-item label="备注信息" prop="remarks"
                :rules="[
                 ]">
          <el-input type="textarea" v-model="inputForm.remarks" placeholder="请填写备注信息"     ></el-input>
           </el-form-item>
        </el-col>
    <el-col :span="24">
     <el-form-item label-width="0">
            <el-tabs v-model="basicPeopleTab">
            <el-tab-pane label="人员学历表">
                  <el-button size="small" @click="addBasicPeopleEducationRow" type="primary">新增</el-button>
                  <el-table
                  class="table"
                  size="small"
                  :data="inputForm.basicPeopleEducationList.filter(function(item){ return item.delFlag !== '1'})"
                  style="width: 100%">
                <el-table-column
                    prop="fullEducation"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="全日制学历学位">
                  </el-table-column>
                <el-table-column
                    prop="fullGraduate"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="全日制毕业院校及专业">
                  </el-table-column>
                <el-table-column
                    prop="fullStart"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="全日制起始时间">
                  </el-table-column>
                <el-table-column
                    prop="fullEnd"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="全日制结束时间">
                  </el-table-column>
                <el-table-column
                    prop="nowEducation"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="在职教育学历学位">
                  </el-table-column>
                <el-table-column
                    prop="nowGraduate"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="在职教育毕业专业">
                  </el-table-column>
                <el-table-column
                    prop="nowStart"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="在职教育起始时间">
                  </el-table-column>
                <el-table-column
                    prop="nowEnd"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="在职教育结束时间">
                  </el-table-column>
                <el-table-column
                    prop="lastEducation"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="最高学历/学位">
                  </el-table-column>
                <!-- <el-table-column
                    prop="sort"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="排序">
                  </el-table-column> -->
                <el-table-column
                    prop="remarks"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="备注信息">
                  </el-table-column>
                  <el-table-column
                    fixed="right"
                    label="操作"
                    width="150">
                    <template slot-scope="scope">
                      <el-button @click="viewBasicPeopleEducationRow(scope.row)" type="text" size="small">查看</el-button>
                      <el-button  @click="editBasicPeopleEducationRow(scope.row)" type="text" size="small">编辑</el-button>
                      <el-button  @click="delBasicPeopleEducationRow(scope.row)" type="text" size="small">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-tab-pane>
            <el-tab-pane label="人员岗位">
                  <el-button size="small" @click="addBasicPeopleJobVoteRow" type="primary">新增</el-button>
                  <el-table
                  class="table"
                  size="small"
                  :data="inputForm.basicPeopleJobVoteList.filter(function(item){ return item.delFlag !== '1'})"
                  style="width: 100%">
                <el-table-column
                    prop="jobNature"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="岗位性质">
                  </el-table-column>
                <el-table-column
                    prop="jobClass"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="岗位分类">
                  </el-table-column>
                <el-table-column
                    prop="jobStatus"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="岗位现状">
                  </el-table-column>
                <!-- <el-table-column
                    prop="sort"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="排序">
                  </el-table-column> -->
                <el-table-column
                    prop="remarks"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="备注信息">
                  </el-table-column>
                  <el-table-column
                    fixed="right"
                    label="操作"
                    width="150">
                    <template slot-scope="scope">
                      <el-button @click="viewBasicPeopleJobVoteRow(scope.row)" type="text" size="small">查看</el-button>
                      <el-button  @click="editBasicPeopleJobVoteRow(scope.row)" type="text" size="small">编辑</el-button>
                      <el-button  @click="delBasicPeopleJobVoteRow(scope.row)" type="text" size="small">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-tab-pane>
            <el-tab-pane label="人员职位">
                  <el-button size="small" @click="addBasicPeoplePositionVoteRow" type="primary">新增</el-button>
                  <el-table
                  class="table"
                  size="small"
                  :data="inputForm.basicPeoplePositionVoteList.filter(function(item){ return item.delFlag !== '1'})"
                  style="width: 100%">
                <el-table-column
                    prop="nowPosFile"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="现任职务(文件)">
                  </el-table-column>
                <el-table-column
                    prop="nowPosSch"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="现任职务(校内)">
                  </el-table-column>
                <el-table-column
                    prop="renNowStart"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="任现职开始时间">
                  </el-table-column>
                <el-table-column
                    prop="renNowEnd"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="任现职结束时间">
                  </el-table-column>
                <el-table-column
                    prop="renNowTime"
                    show-overflow-tooltip
                    label="任现职时长">
                   <template slot-scope="scope">
                     {{ scope.row.renNowStart !== undefined && scope.row.renNowStart !== '' && scope.row.renNowEnd !== undefined && scope.row.renNowEnd !== '' ? (Number(scope.row.renNowEnd.split('.')[0]) - Number(scope.row.renNowStart.split('.')[0])) + '年' + (Number(scope.row.renNowEnd.split('.')[1]) - Number(scope.row.renNowStart.split('.')[1]) >= 0 ? (Number(scope.row.renNowEnd.split('.')[1]) - Number(scope.row.renNowStart.split('.')[1])) + '月' : (Number(scope.row.renNowStart.split('.')[1] - Number(scope.row.renNowEnd.split('.')[1]))) + '月') : '' }}
                   </template>
                  </el-table-column>
                <el-table-column
                    prop="renSameStart"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="任同级开始时间">
                  </el-table-column>
                <el-table-column
                    prop="renSameEnd"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="任同级结束时间">
                  </el-table-column>
                <el-table-column
                    prop="renSameTime"
                    show-overflow-tooltip
                    label="任同级时长">
                    <template slot-scope="scope">
                      {{ scope.row.renSameStart !== undefined && scope.row.renSameStart !== '' && scope.row.renSameEnd !== undefined && scope.row.renSameEnd !== '' ? (Number(scope.row.renSameEnd.split('.')[0]) - Number(scope.row.renSameStart.split('.')[0])) + '年' + (Number(scope.row.renSameEnd.split('.')[1]) - Number(scope.row.renSameStart.split('.')[1]) >= 0 ? (Number(scope.row.renSameEnd.split('.')[1]) - Number(scope.row.renSameStart.split('.')[1])) + '月' : (Number(scope.row.renSameStart.split('.')[1] - Number(scope.row.renSameEnd.split('.')[1]))) + '月') : '' }}
                    </template>
                  </el-table-column>
                <el-table-column
                    prop="majorPos"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="专业技术职务">
                  </el-table-column>
                <el-table-column
                    prop="majorLevel"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="专业技术资格级别">
                  </el-table-column>
                <el-table-column
                    prop="remarks"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="备注信息">
                  </el-table-column>
                  <el-table-column
                    fixed="right"
                    label="操作"
                    width="150">
                    <template slot-scope="scope">
                      <el-button @click="viewBasicPeoplePositionVoteRow(scope.row)" type="text" size="small">查看</el-button>
                      <el-button  @click="editBasicPeoplePositionVoteRow(scope.row)" type="text" size="small">编辑</el-button>
                      <el-button  @click="delBasicPeoplePositionVoteRow(scope.row)" type="text" size="small">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-tab-pane>
            <el-tab-pane label="人员单位行政">
                  <el-button size="small" @click="addBasicPeopleUnitAdminVoteRow" type="primary">新增</el-button>
                  <el-table
                  class="table"
                  size="small"
                  :data="inputForm.basicPeopleUnitAdminVoteList.filter(function(item){ return item.delFlag !== '1'})"
                  style="width: 100%">
                <el-table-column
                    prop="unitName"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="单位名称">
                  </el-table-column>
                <el-table-column
                    prop="unitLevel"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="机构级别">
                  </el-table-column>
                <el-table-column
                    prop="zhengleaderNumber"
                    show-overflow-tooltip
                    label="正处级领导职数">
                    <template slot-scope="scope">
                      {{ scope.row.leaderNumber !== undefined ? scope.row.leaderNumber.split(',')[0] : '' }}
                    </template>
                  </el-table-column>
                  <el-table-column
                      prop="fuleaderNumber"
                      show-overflow-tooltip
                      label="副处级领导职数">
                      <template slot-scope="scope">
                        {{ scope.row.leaderNumber !== undefined ? scope.row.leaderNumber.split(',')[1] : '' }}
                      </template>
                    </el-table-column>
                <el-table-column
                    prop="departName"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="科室名称">
                  </el-table-column>
                <el-table-column
                    prop="departLeaderNum"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="科级领导职数">
                  </el-table-column>
                <el-table-column
                    prop="adminisLevel"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="行政级别">
                  </el-table-column>
                <!-- <el-table-column
                    prop="sort"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="排序">
                  </el-table-column> -->
                <el-table-column
                    prop="remarks"
                    header-align="center"
                    align="center"
                    show-overflow-tooltip
                    label="备注信息">
                  </el-table-column>
                  <el-table-column
                    fixed="right"
                    label="操作"
                    width="150">
                    <template slot-scope="scope">
                      <el-button @click="viewBasicPeopleUnitAdminVoteRow(scope.row)" type="text" size="small">查看</el-button>
                      <el-button  @click="editBasicPeopleUnitAdminVoteRow(scope.row)" type="text" size="small">编辑</el-button>
                      <el-button  @click="delBasicPeopleUnitAdminVoteRow(scope.row)" type="text" size="small">删除</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </el-tab-pane>
            </el-tabs>
           </el-form-item>
          </el-col>
        </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="visible = false">关闭</el-button>
      <el-button size="small" type="primary" v-if="method != 'view'" @click="doSubmit()" v-noMoreClick>确定</el-button>
    </span>
  </el-dialog>
  <BasicPeopleEducationForm ref="basicPeopleEducationForm" @addRow="saveBasicPeopleEducationRow(arguments)"></BasicPeopleEducationForm>
  <BasicPeopleJobVoteForm ref="basicPeopleJobVoteForm" @addRow="saveBasicPeopleJobVoteRow(arguments)"></BasicPeopleJobVoteForm>
  <BasicPeoplePositionVoteForm ref="basicPeoplePositionVoteForm" @addRow="saveBasicPeoplePositionVoteRow(arguments)"></BasicPeoplePositionVoteForm>
  <BasicPeopleUnitAdminVoteForm ref="basicPeopleUnitAdminVoteForm" @addRow="saveBasicPeopleUnitAdminVoteRow(arguments)"></BasicPeopleUnitAdminVoteForm>
</div>
</template>

<script>
  import BasicPeopleEducationForm from './BasicPeopleEducationForm'
  import BasicPeopleJobVoteForm from './BasicPeopleJobVoteForm'
  import BasicPeoplePositionVoteForm from './BasicPeoplePositionVoteForm'
  import BasicPeopleUnitAdminVoteForm from './BasicPeopleUnitAdminVoteForm'
  export default {
    data () {
      return {
        title: '',
        method: '',
        visible: false,
        loading: false,
        basicPeopleTab: '0',
        photoArra: [],
        inputForm: {
          id: '',
          basicPeopleEducationList: [],
          basicPeopleJobVoteList: [],
          basicPeoplePositionVoteList: [],
          basicPeopleUnitAdminVoteList: [],
          peopleName: '',
          gender: '',
          nation: '汉',
          birth: '',
          idNumber: '',
          phoneNumber: '',
          workTime: '',
          partyTime: '',
          employeesCode: '',
          photo: '',
          sort: '',
          remarks: ''
        }
      }
    },
    components: {
      BasicPeopleEducationForm,
      BasicPeopleJobVoteForm,
      BasicPeoplePositionVoteForm,
      BasicPeopleUnitAdminVoteForm
    },
    methods: {
      init (method, id) {
        this.method = method
        if (method === 'add') {
          this.title = `新建基础人员信息`
        } else if (method === 'edit') {
          this.title = '修改基础人员信息'
        } else if (method === 'view') {
          this.title = '查看基础人员信息'
        }
        this.photoArra = []
        this.visible = true
        this.loading = false
        this.$nextTick(() => {
          this.$refs.inputForm.resetFields()
          this.inputForm.id = id
          this.basicPeopleTab = '0'
          this.inputForm.basicPeopleEducationList = []
          this.inputForm.basicPeopleJobVoteList = []
          this.inputForm.basicPeoplePositionVoteList = []
          this.inputForm.basicPeopleUnitAdminVoteList = []
          if (method === 'edit' || method === 'view') { // 修改或者查看
            this.loading = true
            this.$http({
              url: `/basicdata/basicpeople/basicPeople/queryById?id=${this.inputForm.id}`,
              method: 'get'
            }).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data.basicPeople)
              this.inputForm.photo.split('|').forEach((item) => {
                if (item.trim().length > 0) {
                  this.photoArra.push({name: decodeURIComponent(item.substring(item.lastIndexOf('/') + 1)), url: item})
                }
              })
              this.loading = false
            })
          }
        })
      },
      saveBasicPeopleEducationRow (child) {
        if (child[0] === '') {
          this.inputForm.basicPeopleEducationList.push(child[1])
        } else {
          this.inputForm.basicPeopleEducationList.forEach((item, index) => {
            if (item === child[0]) {
              this.inputForm.basicPeopleEducationList.splice(index, 1, child[1])
            }
          })
        }
      },
      addBasicPeopleEducationRow (child) {
        this.$refs.basicPeopleEducationForm.init('add')
      },
      viewBasicPeopleEducationRow (child) {
        this.$refs.basicPeopleEducationForm.init('view', child)
      },
      editBasicPeopleEducationRow (child) {
        this.$refs.basicPeopleEducationForm.init('edit', child)
      },
      delBasicPeopleEducationRow (child) {
        this.inputForm.basicPeopleEducationList.forEach((item, index) => {
          if (item === child && item.id === '') {
            this.inputForm.basicPeopleEducationList.splice(index, 1)
          } else if (item === child) {
            item.delFlag = '1'
            this.inputForm.basicPeopleEducationList.splice(index, 1, item)
          }
        })
      },
      saveBasicPeopleJobVoteRow (child) {
        if (child[0] === '') {
          this.inputForm.basicPeopleJobVoteList.push(child[1])
        } else {
          this.inputForm.basicPeopleJobVoteList.forEach((item, index) => {
            if (item === child[0]) {
              this.inputForm.basicPeopleJobVoteList.splice(index, 1, child[1])
            }
          })
        }
      },
      addBasicPeopleJobVoteRow (child) {
        this.$refs.basicPeopleJobVoteForm.init('add')
      },
      viewBasicPeopleJobVoteRow (child) {
        this.$refs.basicPeopleJobVoteForm.init('view', child)
      },
      editBasicPeopleJobVoteRow (child) {
        this.$refs.basicPeopleJobVoteForm.init('edit', child)
      },
      delBasicPeopleJobVoteRow (child) {
        this.inputForm.basicPeopleJobVoteList.forEach((item, index) => {
          if (item === child && item.id === '') {
            this.inputForm.basicPeopleJobVoteList.splice(index, 1)
          } else if (item === child) {
            item.delFlag = '1'
            this.inputForm.basicPeopleJobVoteList.splice(index, 1, item)
          }
        })
      },
      saveBasicPeoplePositionVoteRow (child) {
        if (child[0] === '') {
          this.inputForm.basicPeoplePositionVoteList.push(child[1])
        } else {
          this.inputForm.basicPeoplePositionVoteList.forEach((item, index) => {
            if (item === child[0]) {
              this.inputForm.basicPeoplePositionVoteList.splice(index, 1, child[1])
            }
          })
        }
      },
      addBasicPeoplePositionVoteRow (child) {
        this.$refs.basicPeoplePositionVoteForm.init('add')
      },
      viewBasicPeoplePositionVoteRow (child) {
        this.$refs.basicPeoplePositionVoteForm.init('view', child)
      },
      editBasicPeoplePositionVoteRow (child) {
        this.$refs.basicPeoplePositionVoteForm.init('edit', child)
      },
      delBasicPeoplePositionVoteRow (child) {
        this.inputForm.basicPeoplePositionVoteList.forEach((item, index) => {
          if (item === child && item.id === '') {
            this.inputForm.basicPeoplePositionVoteList.splice(index, 1)
          } else if (item === child) {
            item.delFlag = '1'
            this.inputForm.basicPeoplePositionVoteList.splice(index, 1, item)
          }
        })
      },
      saveBasicPeopleUnitAdminVoteRow (child) {
        if (child[0] === '') {
          this.inputForm.basicPeopleUnitAdminVoteList.push(child[1])
        } else {
          this.inputForm.basicPeopleUnitAdminVoteList.forEach((item, index) => {
            if (item === child[0]) {
              this.inputForm.basicPeopleUnitAdminVoteList.splice(index, 1, child[1])
            }
          })
        }
      },
      addBasicPeopleUnitAdminVoteRow (child) {
        this.$refs.basicPeopleUnitAdminVoteForm.init('add')
      },
      viewBasicPeopleUnitAdminVoteRow (child) {
        this.$refs.basicPeopleUnitAdminVoteForm.init('view', child)
      },
      editBasicPeopleUnitAdminVoteRow (child) {
        this.$refs.basicPeopleUnitAdminVoteForm.init('edit', child)
      },
      delBasicPeopleUnitAdminVoteRow (child) {
        this.inputForm.basicPeopleUnitAdminVoteList.forEach((item, index) => {
          if (item === child && item.id === '') {
            this.inputForm.basicPeopleUnitAdminVoteList.splice(index, 1)
          } else if (item === child) {
            item.delFlag = '1'
            this.inputForm.basicPeopleUnitAdminVoteList.splice(index, 1, item)
          }
        })
      },
      // 表单提交
      doSubmit () {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$http({
              url: `/basicdata/basicpeople/basicPeople/save`,
              method: 'post',
              data: this.inputForm
            }).then(({data}) => {
              this.loading = false
              if (data && data.success) {
                this.visible = false
                this.$message.success(data.msg)
                this.$emit('refreshDataList')
              }
            })
          }
        })
      }
    }
  }
</script>
